﻿@using Ed.Entity
@using System.Web.Optimization
@using Ed.Web.Helpers
@model Ed.Entity.TSysUser
@{
    //页面类型
    var actionType = ViewBag.ActionType;
    Layout = null;  
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加/修改用户信息</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" conte="conte" nt="IE=Edge" />
    @Styles.Render("~/Themes/default/css/cp.globle.min1.css")
    @Scripts.Render("~/Themes/default/js/cp.globle.min1.js")
    <!--去除顶层加载中 14-10-17 By 唐有炜-->
    <script type="text/javascript">
        //=============================================================
        //去除顶层加载中
        $(document).ready(function () {
            //去除加载中
            if (undefined != top.dialog.list["show_loading"]) {
                top.dialog.list["show_loading"].close().remove();
                //showTopMsg("页面加载成功！", "温馨提示", "Success");
            }
        });
        //=====================================================================
    </script>
    <!--my97DatePicker-->
    <script src="/Themes/default/lib/my97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <!--省市数据-->
    <script src="/Themes/default/base/js/city.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
        validate_form();
    });
    //表单验证
    function validate_form() {
        //表单验证
        $("#sysuser_form").validate({          
            rules: {
           @if (@actionType == "Add")
           {
               //验证手机号是否存在
                        @Html.Raw("UserLname: {remote: { type: 'GET', url: '/api/SysUserApi/Validate?fields=UserLname&eqs==&operations=AND&existReturn=false', data: { values: function () { return $('#UserLname').val(); } } }}")                                                           
           }
           },        
    messages: {
        UserLname: {
                remote: "该登陆名称已存在，请勿重复添加用户！"
            }  },
      invalidHandler: function (e, validator) {
                var msg = "有 " + validator.numberOfInvalids() + " 项填写有误，请检查！";
                $("#msgprint").html(msg).show().focus();
                setTimeout(function () {
                    $("#msgprint").fadeOut(500);
                    //如果动画结束则删除节点
                    if (!$("#msgprint").is(":animated")) {
                        $("#msgprint").hide();
                    }
                }, 1000);
            },
            focusInvalid: false,
            errorPlacement: function (error, element) {
                var errorMsg = error[0].innerHTML;
                var elementName = element[0].name;
                $("#" + elementName).formtip(errorMsg);
                $("#" + elementName).attr("placeholder", errorMsg);
            },
            success: function (element) {
                var elem = $(element)[0].htmlFor;
                $("#" + elem).poshytip('disable');
                $("#" + elem).poshytip('destroy');
                $("#" + elem).removeClass("error").addClass("success");
            }
        });
    }

    //表单验证方法，供父窗口调用
    function form_valid() {
        if ($("#sysuser_form").valid()) {
            return true;
        } else {
            return false;
        }
    }
    </script>
</head>
<body>
    <form id="sysuser_form" name="sysuser_form">
    <!--id-->
    @Html.HiddenFor(model => model.Id)
    <!--表单错误提示区-->
    <div tabindex="-1" id="msgprint" class="warning" style="position: fixed; width: 90%;
        display: none;">
        您的表单包含错误，请检查！</div>
    <div class="tab-content">
        <ul class="nav nav-tabs" id="formTab">
            <li class="active"><a href="#tab-info" data-toggle="tab">登录用户/员工基本信息</a></li>
        </ul>
        <div class="tab-pane active" id="tab-info">
            <div style="height: 15px;">
            </div>
            <table width="800" border="0" cellspacing="0" cellpadding="0" class="commontable shortSelect">
                <tbody>
                    <tr>
                        <th>
                            <span class="must">*</span>用户登录名：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserLname, new { @class = "form-control", @style = "width: 200px; color:blue", @placeholder = "唯一性登录名称" })
                        </td>
                        <th>
                            <span class="must">*</span>登录密码：
                        </th>
                        <td>
                            @Html.PasswordFor(model => model.UserPassword, new { @class = "form-control", @style = "width: 200px; ", @placeholder = "" })
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span class="must">*</span>真实姓名：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserTname, new { @class = "form-control", @style = "width: 200px; ", @placeholder = "真实姓名" })
                        </td>
                        <th>
                            用户性别：
                        </th>
                        <td>
                            @Html.DropDownListFor(model => model.UserSex, @Html.BuildSelectList("1|男,2|女", "0"), new { @class = "form-control", @style = "width:200px;" })
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span class="must">*</span>手机号：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserPhone, new { @class = "form-control required", @style = "width: 200px; ", @placeholder = "" })
                        </td>
                        <th>
                            用户邮箱：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserEmail, new { @class = "form-control", @style = "width: 200px; ", @placeholder = "真实性邮箱" })
                        </td>
                    </tr>
                    <tr>
                        <th>
                            联系电话：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserTel, new { @class = "form-control", @style = "width: 200px; ", @placeholder = "" })
                        </td>
                        <th>
                            用户QQ：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserQq, new { @class = "form-control", @style = "width: 200px; ", @placeholder = "" })
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span class="must">*</span>所属部门：
                        </th>
                        <td>
                            @if (@Session[EdKeys.SESSION_ROLE_ID].ToString() == "1")
                            {                                 
                                @Html.DropDownListFor(model => model.DepId, ViewData["listDepartment"] as SelectList, "请选择", new { @class = "form-control required", @style = "width: 200px; ", @placeholder = "" })
                            }
                            else
                            {
@*@Html.DropDownListFor(model => model.DepId, @Html.BuildSelectList(@createrId + "|" + @createrName, @Html.LoadDefaultValue(Model.PInfoCreateperson, @createrId.ToString()).ToString(), false), new { @class = "form-control", @style = "width:200px;", @disabled = "disabled" })*@
                                <div color="gray">
                                    本部门</div>
                            }
                        </td>
                        <th>
                            <span class="must">*</span>所属角色：
                        </th>
                        <td>
                            @if (@Session[EdKeys.SESSION_ROLE_ID].ToString() == "2")
                            {
                                @Html.DropDownListFor(model => model.RoleId, @Html.BuildSelectList("6|业务员/点,5|客户经理,4|信息维护人员", "0"), new { @class = "form-control required", @style = "width:200px;" })
                            }
                            else
                            {
                                @Html.DropDownListFor(model => model.RoleId, @Html.BuildSelectList("2|地区管理员,6|业务员/点,5|客户经理,4|信息维护人员,5|超级管理员", "0"), new { @class = "form-control required", @style = "width:200px;" })
                            }
                        </td>
                    </tr>
                    <tr>
                        <th>
                            是否启用：
                        </th>
                        <td>
                            @Html.DropDownListFor(model => model.UserEnable, @Html.BuildSelectList("0|禁用,1|启用", @Html.LoadDefaultValue(Model.UserEnable, "1").ToString(), false), new { @class = "form-control required", @style = "width:200px;", Value = "1"})                          
                        </td>
                        <th>
                            添加日期：
                        </th>
                        <td>
                            @Html.TextBoxFor(model => model.UserRegDate, new { @class = "form-control isreadonly", Value = @Html.LoadDefaultValue(@Html.DateTimeNullPalse(Model.UserRegDate).ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd")), @onfocus = "this.blur()", @style = "width:200px;" })
                        </td>
                    </tr>                   
                </tbody>
            </table>
        </div>
    </div>
    </form>
</body>
